﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{

    class DBhelper
    {
        private static readonly string str = "server=.;database=Schools;uid=sa;pwd=398611;";

        public static DataTable GetDataTable(string sql)
        {
            SqlConnection connection = new SqlConnection(str);

            SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);

            connection.Open();

            DataTable table = new DataTable();

            adapter.Fill(table);

            return table;
        }

        public static int AddOrUpdateOrdelete(String sql)
        {
            SqlConnection connection = new SqlConnection(str);

            SqlCommand command = new SqlCommand(sql, connection);

            connection.Open();

            return command.ExecuteNonQuery();
        }
    }

    
}
